﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace HostComputerPlatform.Views
{
    /// <summary>
    /// InputDialogWindow.xaml 的交互逻辑
    /// </summary>
    public partial class InputDialogWindow : Window, INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        private string _windowTitle;
        public string WindowTitle
        {
            get => _windowTitle;
            set
            {
                _windowTitle = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(WindowTitle)));
            }
        }

        private string _promptText;
        public string PromptText
        {
            get => _promptText;
            set
            {
                _promptText = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(PromptText)));
            }
        }

        private string _inputText;
        public string InputText
        {
            get => _inputText;
            set
            {
                _inputText = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(InputText)));
            }
        }

        public InputDialogWindow(string title, string prompt, string defaultValue = "")
        {
            InitializeComponent();
            WindowTitle = title;
            PromptText = prompt;
            InputText = defaultValue;
            DataContext = this;
            InputTextBox.Focus();
            InputTextBox.SelectAll();
        }

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = true;
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
        }
    }
}
